<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">
    <div>{{pmsg}}</div>
    <menu-item :pstr="pstr" :pnum="12" :pboo="true" :parr="parr" :pobj="pobj"></menu-item>
</div>

<!-- 开发环境版本，包含了有帮助的命令行警告 -->
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script type="text/javascript">
    /*
    父组件向子组件传值-props属性值类型
     */
    Vue.component("menu-item", {
        props: ["pstr", "pnum", "pboo", "parr", "pobj"],
        template: `
            <div>
                <div>{{typeof pstr}} {{pstr}}</div>
                <div>{{typeof pnum}} {{12 + pnum}}</div>
                <div>{{typeof pboo}} {{pboo}}</div>
                <ul>
                    <li :key="index" v-for="(item,index) in parr">{{item}}</li>
                </ul>
                <div>
                    <span>{{pobj.name}}</span>
                    <span>{{pobj.age}}</span>
                </div>
            </div>
        `
    })

    var vue = new Vue({
        el: "#app",
        data: {
            pmsg: "父组件中的内容",
            pstr: "hello",
            parr: ["apple", "huawei", "samsung"],
            pobj: {
                name: "詹姆斯·高斯林",
                age: "65"
            }
        }
    })
</script>
</body>
</html>
